home *** CD-ROM | disk | FTP | other *** search
/ Amiga CD-Sensation: Golden Games / Amiga CD-Sensation - Ausgabe 2 - Golden Games (1996)(GTI - Schatztruhe)(DE)[!].iso / Brain Activity / 10000 / src / 10000.C next >
C/C++ Source or Header  |  1995-12-06  |  21KB  |  812 lines

  1. /* TEN THOUSAND */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <stddef.h>
  5. #include <time.h>
  6. #include <string.h>
  7. #include <math.h>
  8. #include <ctype.h>
  9. #define AMI 1
  10. #if(AMI)
  11. #include "10000ami.h"
  12. #else
  13. #include "10000ibm.h"
  14. #endif
  15.  
  16. /*** DEFINE EXTERNALS ***/
  17. int min = 1000, psc[8], sr[5], dice[5], n[6], nhp, np, cp, dtr, rt, poss,
  18.   hs, tt, analyse (int), ran (int), legal[5], oldrt, olddtr, sel, compdec (void),
  19.   playsleft, new (void), fob, pob;
  20. void putbox (int), drawbox (int), activatebox (int), roll (void), instr (void),
  21.   quit (int), wait (int), drawbutton (int, int, char[], int), itsa2000 (void),
  22.   zonk (void), wazoo (void), throwback (void), updatert (void);
  23. char pnm[8][8] =
  24. {"ÄÄÄÄÄÄÄ", "ÄÄÄÄÄÄÄ", "ÄÄÄÄÄÄÄ", "ÄÄÄÄÄÄÄ", "ÄÄÄÄÄÄÄ", "ÄÄÄÄÄÄÄ",
  25.  "ÄÄÄÄÄÄÄ", "ÄÄÄÄÄÄÄ"};
  26. char pbox[4][10] =
  27. {"ÚÄÄÄÄÄÄÄ¿", "³       ³", "³       ³", "ÀÄÄÄÄÄÄÄÙ"};
  28. char rollbox[3][12] =
  29. {"ÚÄÄÄÄÄÄÄÄÄ¿", "³         ³", "ÀÄÄÄÄÄÄÄÄÄÙ"};
  30. char scorebox[3][12] =
  31. {"ÜÜÜÜÜÜÜÜÜÜÜ", "Û         Û", "ßßßßßßßßßßß"};
  32. char button[3][20] =
  33. {"ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·", "³                 º", "ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"};
  34. char activebutton[3][20] =
  35. {"ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ", "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ", "ßßßßßßßßßßßßßßßßßßß"};
  36. char die1a[12] = "ÜÜÜÜÜÜÜÜÜÜÜ", die1b[12] = "ÝÜÜÜÜÜÜÜÜÜÞ", die2[12] = "ÝÛÛÛÛÛÛÛÛÛÞ",
  37.   die3a[12] = "ÝßßßßßßßßßÞ", die3b[12] = "ßßßßßßßßßßß";
  38. char die[6][3][12] =
  39. {
  40.   {"ÝÛÛÛÛÛÛÛÛÛÞ", "ÝÛÛÛÛ ÛÛÛÛÞ", "ÝÛÛÛÛÛÛÛÛÛÞ"},
  41.   {"ÝÛ ÛÛÛÛÛÛÛÞ", "ÝÛÛÛÛÛÛÛÛÛÞ", "ÝÛÛÛÛÛÛÛ ÛÞ"},
  42.   {"ÝÛ ÛÛÛÛÛÛÛÞ", "ÝÛÛÛÛ ÛÛÛÛÞ", "ÝÛÛÛÛÛÛÛ ÛÞ"},
  43.   {"ÝÛ ÛÛÛÛÛ ÛÞ", "ÝÛÛÛÛÛÛÛÛÛÞ", "ÝÛ ÛÛÛÛÛ ÛÞ"},
  44.   {"ÝÛ ÛÛÛÛÛ ÛÞ", "ÝÛÛÛÛ ÛÛÛÛÞ", "ÝÛ ÛÛÛÛÛ ÛÞ"},
  45.   {"ÝÛ ÛÛÛÛÛ ÛÞ", "ÝÛ ÛÛÛÛÛ ÛÞ", "ÝÛ ÛÛÛÛÛ ÛÞ"}};
  46. char strangename[8][8] =
  47. {"Sven", "Helga", "Sigmund", "Buffy", "Dweezil", "Claude", "Ursula", "Arturo"};
  48.  
  49. main (int argc, char argv[])
  50. {
  51.   int i, j;
  52.   char temp[80], temp2[2], temp3[5];
  53.   srand ((int) time (NULL));
  54.   for (i = 1; i <= ran (20); i++)
  55.     ran (i);    /*** This eliminates the preliminary repetition in the random # generator ***/
  56. #if(AMI)
  57.     {
  58.       setupamigascreen ();
  59.       uamenu (G, 1, 0, 0, "Ten Thousand", ' ', 0, MIDRAWN | MENUENABLED, 0);
  60.       uamenu (G, 1, 1, 0, "Quit programme", 'Q', 0, MIDRAWN | ITEMTEXT | HIGHBOX | ITEMENABLED | COMMSEQ, (int (*)()) quit);
  61.     }
  62. #endif
  63.  
  64. NEWGAME:
  65.   cls ();
  66.   drawpic ();
  67.   colour (15, 2);
  68.   if (ask (23, "Dost thou require instructions"))
  69.     instr ();
  70. clear(23);
  71.   do
  72.     {
  73.       colour (5, 0);
  74.       prompt (23, "How many human players are there (0-8 or [Q]uit)?", temp2, 1);
  75.       if (toupper (temp2[0]) == 'Q')
  76.     quit (23);
  77.       nhp = (int) temp2[0] - 48;
  78.     }
  79.   while (nhp < 0 || nhp > 8);
  80.   if (nhp > 0) {clear(23);
  81.     for (i = 1; i <= nhp; i++)
  82.       {
  83.     colour (11, 2);
  84.     sprintf (temp, "Name of player #%1d (7 characters max.):", i);
  85.     prompt (23, temp, pnm[i - 1], 7);
  86.     pnm[i - 1][0] = toupper (pnm[i - 1][0]);
  87.       }}
  88.   if (nhp < 8)
  89.     {clear(23);
  90.       sprintf (temp, "How many computer players (0-%1d or [Q]uit)?", 8 - nhp);
  91.       do
  92.     {
  93.       colour (12, 0);
  94.       prompt (23, temp, temp2, 1);
  95.       if (toupper (temp2[0]) == 'Q')
  96.         quit (23);
  97.       np = (int) temp2[0] - 48;
  98.     }
  99.       while (np < 0 || np > (8 - nhp));
  100.       np = nhp + np;
  101.       if (np == 0)
  102.     { clear(23);
  103.       colour (15, 0);
  104.       centre (23, "No players selected!  Exiting...");
  105.       wait (2);
  106.       #if(AMI)
  107.           UEND ();
  108.       #else
  109.         cls ();
  110.       #endif
  111.       exit (1);
  112.     }
  113.       if ((np - nhp) == 1)
  114.     strcpy (pnm[np - 1], "Hal");
  115.       else
  116.     for (i = nhp + 1; i <= np; i++)
  117.       strcpy (pnm[i - 1], strangename[i - nhp - 1]);
  118.     }
  119.  
  120. /*** SET UP SCREEN ***/
  121.   cls ();
  122.   cp = 0;
  123.   for (i = 1; i <= np; i++)
  124.     {
  125.       psc[i - 1] = 0;
  126.       drawbox (i);
  127.     }
  128.   fob = 0;
  129.   pob = 0;
  130.   colour (7, 0);
  131.   display (25, 1, "°±² RUNNING TOTAL  =      ²±°");
  132.   display (25, 51, "°±² TOTAL POSSIBLE =      ²±°");
  133.   drawbutton (1, 5, "[N]ew game", 0);
  134.   drawbutton (2, 6, "keep [R]olling", 0);
  135.   drawbutton (3, 2, "[S]top/take score", 0);
  136.   drawbutton (4, 3, "[Q]uit programme", 0);
  137.  
  138. NEXTPLAYER:
  139.   if (tt)
  140.     {
  141.       playsleft--;
  142.       if (playsleft == 0)
  143.     {
  144.       activatebox (hs);
  145.       clearlines (6, 21);
  146.       drawbutton (1, 3, pnm[hs - 1], 1);
  147.       drawbutton (2, 2, "IS", 0);
  148.       drawbutton (3, 6, "THE", 0);
  149.       drawbutton (4, 5, "WINNER", 1);
  150.       clear (25);
  151.       colour (11, 4);
  152.       pause ();
  153.       if (new ())
  154.         goto NEWGAME;
  155.       else
  156.         {
  157.           #if(AMI)
  158.           UEND ();
  159.           #else
  160.         cls ();
  161.     #endif
  162.           exit (1);
  163.         }
  164.     }
  165.     }
  166.   cp++;
  167.   if (cp > np)
  168.     cp = 1;
  169.   if (fob != 0 && cp == fob && pob >= 0)
  170.     pob++;
  171.   if (pob == 5)
  172.     {
  173.       pob = -1;
  174.       colour (10, 0);
  175.       centre (21, "Minimum to get on the board is now 500.");
  176.       min = 500;
  177.       wait (3);
  178.     }
  179.   rt = 0;
  180.   activatebox (cp);
  181.   dtr = 5;
  182.  
  183. ROLLSOMEDICE:
  184.   oldrt = rt;
  185.   if (dtr <= 0)
  186.     dtr = 5;
  187.   roll ();
  188.   olddtr = dtr;
  189.   poss = analyse (0);
  190.   sel = 0;
  191.   for (i = 0; i <= dtr - 1; i++)
  192.     {
  193.       if ((dice[i] == 1) || (dice[i] == 5))
  194.     legal[i] = 1;
  195.       else if ((n[dice[i] - 1] >= 3) && (sel < 3))
  196.     {
  197.       legal[i] = 1;
  198.       sel++;
  199.     }
  200.     }
  201.   colour (15, 0);
  202.   sprintf (temp3, "%.4d", poss);
  203.   display (25, 72, temp3);
  204.   if (poss == 2000)
  205.     itsa2000 ();
  206.   else if (poss == 0)
  207.     {
  208.       if (dtr == 5)
  209.     wazoo ();
  210.       else
  211.     zonk ();
  212.       drawbox (cp);
  213.       goto NEXTPLAYER;
  214.     }
  215.   for (i = 1; i <= olddtr; i++)
  216.     putbox (i);
  217.   updatert ();
  218.   clear (21);
  219.   colour (0, 7);
  220.   centre (21, "ÄÄ Select dice to score or re-roll ÄÄ");
  221.   drawbutton (2, 6, "keep [R]olling", 0);
  222.   drawbutton (3, 2, "[S]top/take score", 0);
  223.  
  224. GETKEY:
  225.   if (cp > nhp)
  226.     {
  227.       if (compdec ())
  228.     j = 35;
  229.       else
  230.     j = 34;
  231.       for (i = 1; i <= olddtr; i++)
  232.     if (sr[i - 1])
  233.       {
  234.         putbox (i);
  235.         dtr--;
  236.       }
  237.       wait (2);
  238.       #if(AMI)
  239.       i = checkinput ();
  240.       if (i == 30 || i == 33)
  241.         j = i;
  242.       #endif
  243.     }
  244.   else
  245.     j = getinput ();
  246.   if ((j >= 1) && (j <= olddtr))
  247.     {
  248.       if (legal[j - 1])
  249.     {
  250.       sr[j - 1] = 1 - sr[j - 1];
  251.       updatert ();
  252.       putbox (j);
  253.       dtr = dtr - 2 * sr[j - 1] + 1;
  254.     }
  255.       goto GETKEY;
  256.     }
  257.   else if (j == 33)
  258.     {
  259.       drawbutton (4, 3, "[Q]uit programme", 1);
  260.       quit (21);
  261.       drawbutton (4, 3, "[Q]uit programme", 0);
  262.       goto GETKEY;
  263.     }
  264.   else if (j == 34)
  265.     {
  266.       drawbutton (2, 6, "keep [R]olling", 1);
  267.       if (dtr == olddtr)
  268.     {
  269.       clear (21);
  270.       colour (15, 0);
  271.       centre (21, "You must keep at least one die!");
  272.       wait (2);
  273.       drawbutton (2, 6, "keep [R]olling", 0);
  274.       goto GETKEY;
  275.     }
  276.       goto ROLLSOMEDICE;
  277.     }
  278.   else if (j == 35)
  279.     {
  280.       drawbutton (3, 2, "[S]top/take score", 1);
  281.       if (rt == 0)
  282.     {
  283.       clear (21);
  284.       colour (15, 0);
  285.       centre (21, "Your running total is zero!");
  286.       wait (2);
  287.  
  288.     }
  289.       else if ((psc[cp - 1] + rt) < min)
  290.     {
  291.       colour (15, 0);
  292.       sprintf (temp, "You need at least %1d to get on the board!", min);
  293.       centre (21, temp);
  294.       wait (2);
  295.     }
  296.       else
  297.     {
  298.       if (fob == 0)
  299.         fob = cp;
  300.       psc[cp - 1] = psc[cp - 1] + rt;
  301.       if (psc[cp - 1] > psc[hs - 1])
  302.         hs = cp;
  303.       activatebox (cp);
  304.       if (psc[cp - 1] >= 10000)
  305.         {
  306.           if (!tt)
  307.         {
  308.           sprintf (temp, "%s is over 10000.  LAST ROUND OF PLAY!", pnm[cp - 1]);
  309.           tt = 1;
  310.           hs = cp;
  311.           playsleft = np;
  312.           clear (21);
  313.           colour (15, 0);
  314.           centre (21, temp);
  315.         }
  316.         }
  317.       drawbox (cp);
  318.       goto NEXTPLAYER;
  319.     }
  320.       drawbutton (3, 2, "[S]top/take score", 0);
  321.     }
  322.   else if (j == 30)
  323.     {
  324.       drawbutton (1, 5, "[N]ew game", 1);
  325.       if (new ())
  326.     goto NEWGAME;
  327.       drawbutton (1, 5, "[N]ew game", 0);
  328.     }
  329.   goto GETKEY;
  330. }
  331.  
  332. /*** UPDATE RUNNING TOTAL ***/
  333. void
  334. updatert (void)
  335. {
  336.   char temp3[5];
  337.   rt = oldrt + analyse (1);
  338.   colour (15, 0);
  339.   sprintf (temp3, "%.4d", rt);
  340.   display (25, 22, temp3);
  341. }
  342.  
  343. /*** COMPUTER DECISION (YAWN...) ***/
  344. int
  345. compdec (void)
  346. {
  347.   int i;
  348.   sel = 0;
  349.   for (i = 1; i <= olddtr; i++)
  350.     {
  351.       sr[i - 1] = legal[i - 1];
  352.       if (sr[i - 1])
  353.     sel++;
  354.     }
  355.   updatert ();
  356.   if (psc[cp - 1] >= min)
  357.     {
  358.       if (sel == olddtr)
  359.     {
  360.       if (ran (5) <= 4)
  361.         return (0);
  362.       else
  363.         return (1);
  364.     }
  365.       else if (rt >= 200)
  366.     {
  367.       if (rand () / (RAND_MAX + 1.0) <= (float) (rt * 5 / (olddtr - sel) * (psc[hs - 1] - psc[cp - 1] + 1)))
  368.         return (1);
  369.       else
  370.         {
  371.           throwback ();
  372.           return (0);
  373.         }
  374.     }
  375.       else
  376.     {
  377.       throwback ();
  378.       return (0);
  379.     }
  380.     }
  381.   else
  382.     {
  383.       if (rt >= min)
  384.     {
  385.       if (sel == olddtr)
  386.         {
  387.           if (ran (5) == 3)
  388.         return (0);
  389.           else
  390.         return (1);
  391.         }
  392.       else
  393.         return (1);
  394.     }
  395.       else
  396.     {
  397.       if (sel != olddtr)
  398.         throwback ();
  399.       return (0);
  400.     }
  401.     }
  402. }
  403.  
  404. /*** THROW BACK 50's (COMPUTER DECISION) ***/
  405. void
  406. throwback (void)
  407. {
  408.   int i, j = analyse (1);
  409.   if (j == 50 || n[4] == 3)
  410.     return;
  411.   else
  412.     for (i = 1; i <= olddtr; i++)
  413.       {
  414.     if (dice[i - 1] == 5 && sel > 1)
  415.       {
  416.         sr[i - 1] = 0;
  417.         updatert ();
  418.         sel--;
  419.         if ((rt - oldrt) == 500)
  420.           return;
  421.       }
  422.       }
  423. }
  424.  
  425. /*** 2000! (WHOOPEE!) ***/
  426. void
  427. itsa2000 (void)
  428. {
  429.   int i;
  430.   colour (11, 5);
  431.   centre (17, "ÖÄÄÄÄÄ·       ÖÄÄÄÄÄ·       ÖÄÄÄÄÄ·       ÖÄÄÄÄÄ·       Ò Ò Ò ·");
  432.   colour (11, 6);
  433.   centre (18, "ÖÄÄÄÄĽ       º     º       º     º       º     º       Ð Ð Ð Ð");
  434.   colour (11, 2);
  435.   centre (19, "ÓÄÄÄÄĽ       ÓÄÄÄÄĽ       ÓÄÄÄÄĽ       ÓÄÄÄÄĽ       Ð Ð Ð Ð");
  436.   for (i = 0; i <= 4; i++)
  437.     {
  438.       if (cp <= nhp)
  439.     {
  440.       sr[i] = 1;
  441.       legal[i] = 0;
  442.     }
  443.       else
  444.     {
  445.       sr[i] = 0;
  446.       legal[i] = 1;
  447.     }
  448.     }
  449.   dtr = 0;
  450.   colour (10, 2);
  451.   wait (3);
  452.   clearlines (17, 19);
  453. }
  454.  
  455. /*** GRAND WAZOO (BUMMER, MAN) ***/
  456. void
  457. wazoo (void)
  458. {
  459.   colour (15, 0);
  460.   centre (17, "Ö     ·       ÖÄÄÄÄÄ·       ÖÄÄÄÄÄ·       ÖÄÄÄÄÄ·       ÖÄÄÄÄÄ·");
  461.   colour (7, 0);
  462.   centre (18, "º  º  º GRAND ÇÄÄÄÄĶ ÄÄÄÄÄ ÖÄÄÄÄĽ ÄÄÄÄÄ º     º ÄÄÄÄÄ º     º");
  463.   colour (8, 0);
  464.   centre (19, "ÓÄÄÐÄĽ       Ó     ½       ÓÄÄÄÄÄÄ       ÓÄÄÄÄĽ       ÓÄÄÄÄĽ");
  465.   colour (9, 1);
  466.   wait (3);
  467. }
  468.  
  469. /*** ZONK! (Swahili for: "hey ya hoser, ya gots no score, eh.") ***/
  470. void
  471. zonk (void)
  472. {
  473.   int i;
  474.   colour (11, 0);
  475.   display (17, 24, "ÚÄÄÄÄÄ¿ ÚÄÄÄÄÄ¿ ÚÄÄ¿  ¿ Ú     ¿");
  476.   colour (3, 0);
  477.   display (18, 24, "ÚÄÄÄÄÄÙ ³     ³ ³  ³  ³ ÃÄÄÄÂÄÙ");
  478.   colour (1, 0);
  479.   display (19, 24, "ÀÄÄÄÄÄÄÄÀÄÄÄÄÄÙÄÀ  ÀÄÄÙÄÀ   ÀÄÄÄ");
  480.   colour (5, 0);
  481.   for (i = 0; i <= 2; i++)
  482.     {
  483.       display (17 + i, 20, "°±²");
  484.       display (17 + i, 59, "²±°");
  485.     }
  486.   wait (2);
  487. }
  488.  
  489. /*** ANALYSE DICE TO DETERMINE RUNNING TOTAL OR TOTAL POSSIBLE ***/
  490. int
  491. analyse (int isrt)
  492. {
  493.   int i, j = 0;
  494.   for (i = 0; i <= 5; i++)
  495.     n[i] = 0;
  496.   for (i = 0; i <= olddtr - 1; i++)
  497.     n[dice[i] - 1] = n[dice[i] - 1] + isrt * sr[i] + (1 - isrt);
  498.   for (i = 1; i <= 6; i++)
  499.     {
  500.       if (n[i - 1] == 5)
  501.     return (2000);
  502.       else if (n[i - 1] >= 3)
  503.     {
  504.       j = j + 100 * i;
  505.       if (i == 1)
  506.         j = j + 900;
  507.     }
  508.     }
  509.   j = j + 50 * (n[4] % 3);
  510.   j = j + 100 * (n[0] % 3);
  511.   return (j);
  512. }
  513.  
  514. /*** DRAW A SPECIFIC MENU BUTTON ***/
  515. void
  516. drawbutton (int num, int col, char text[], int act)
  517. {
  518.   int k = (num - 1) * 20 + 1, i;
  519.   colour (col, 0);
  520.   if (act)
  521.     {
  522.       for (i = 0; i <= 2; i++)
  523.     display (22 + i, k, activebutton[i]);
  524.       colour (col + 8, col);
  525.       display (23, k + 9 - (int) strlen (text) / 2, text);
  526.     }
  527.   else
  528.     {
  529.       for (i = 0; i <= 2; i++)
  530.     display (22 + i, k, button[i]);
  531.       colour (col + 8, 0);
  532.       display (23, k + 9 - (int) strlen (text) / 2, text);
  533.     }
  534. }
  535.  
  536. /*** DRAW SCORE/REROLL BOXES ***/
  537. void
  538. putbox (int j)
  539. {
  540.   int i, k;
  541.   k = 28 - 7 * olddtr + 14 * j;
  542.   if (sr[j - 1])
  543.     {
  544.       colour (2, 0);
  545.       for (i = 0; i <= 2; i++)
  546.     display (17 + i, k, scorebox[i]);
  547.       colour (11, 2);
  548.       display (18, k + 1, "S C O R E");
  549.     }
  550.   else
  551.     {
  552.       colour (1, 0);
  553.       for (i = 0; i <= 2; i++)
  554.     display (17 + i, k, rollbox[i]);
  555.       colour (9, 0);
  556.       display (18, k + 1, "ROLL OVER");
  557.     }
  558. }
  559.  
  560. /*** DRAW PLAYER BOX (NORMAL) ***/
  561. void
  562. drawbox (int player)
  563. {
  564.   int left = 32 - 5 * np + player * 10, i;
  565.   if (player > nhp)
  566.     colour (4, 0);
  567.   else
  568.     colour (5, 0);
  569.   display (1, left - 1, "          ");
  570.   for (i = 1; i <= 4; i++)
  571.     {
  572.       display (i + 1, left, pbox[i - 1]);
  573.       display (i + 1, left - 1, " ");
  574.     }
  575.   colour (7, 0);
  576.   displayint (3, left + 4 - (int) ((log10 ((float) (psc[player - 1] + 1)) + 1) / 2), psc[player - 1]);
  577.   display (4, left + 4 - (int) (strlen (pnm[player - 1]) / 2), pnm[player - 1]);
  578. }
  579.  
  580. /*** DRAW PLAYER BOX (ACTIVATED) ***/
  581. void
  582. activatebox (int player)
  583. {
  584.   int i, left = 31 - 5 * np + player * 10;
  585.   if (player > nhp)
  586.     colour (12, 0);
  587.   else
  588.     colour (13, 0);
  589.   for (i = 1; i <= 4; i++)
  590.     display (i, left, pbox[i - 1]);
  591.   colour (15, 0);
  592.   displayint (2, left + 4 - (int) ((log10 ((float) (psc[player - 1] + 1)) + 1) / 2), psc[player - 1]);
  593.   display (3, left + 4 - (int) (strlen (pnm[player - 1]) / 2), pnm[player - 1]);
  594. }
  595.  
  596. /*** ROLL DICE ***/
  597. void
  598. roll (void)
  599. {
  600.   int i, k;
  601.   char temp[2];
  602.   clearlines (7, 19);
  603.   for (i = 1; i <= dtr; i++)
  604.     {
  605.       if (strcmp (pnm[0], "óðéîù¹µ") == 0)
  606.     {
  607.       do
  608.         {
  609.           prompt (21, "Enter #:", temp, 1);
  610.         }
  611.       while (temp[0] < '1' || temp[0] > '6');
  612.       dice[i - 1] = (int) temp[0] - 48;
  613.     }
  614.       else
  615.     dice[i - 1] = ran (6);
  616.       sr[i - 1] = 0;
  617.       legal[i - 1] = 0;
  618.       k = 28 - 7 * dtr + 14 * i;
  619.       colour (15, 0);
  620.       display (7, k, die1a);
  621.       colour (7, 0);
  622.       display (8, k, die1b);
  623.       display (9, k, die[dice[i - 1] - 1][0]);
  624.       display (10, k, die2);
  625.       display (11, k, die[dice[i - 1] - 1][1]);
  626.       display (12, k, die2);
  627.       display (13, k, die[dice[i - 1] - 1][2]);
  628.       display (14, k, die3a);
  629.       colour (8, 0);
  630.       display (15, k, die3b);
  631.       colour (6, 0);
  632.       displayint (16, k + 5, i);
  633.     }
  634. }
  635.  
  636.  
  637. /*** GENERATE A RANDOM INTEGER BETWEEN 1 AND K ***/
  638. int
  639. ran (int k)
  640. {
  641.   double x = RAND_MAX + 1.0;
  642.   int y;
  643.   y = 1 + rand () * (k / x);
  644.   return (y);
  645. }
  646.  
  647. /*** INSTRUCTIONS ***/
  648. void
  649. instr (void)
  650. {
  651.   cls ();
  652.   colour (5, 0);
  653.   display (1, 1, "ÚÄÄÄÄÄÄÄÄÄÄ·");
  654.   display (2, 1, "³ THE GAME º");
  655.   display (3, 1, "ÔÍÍÍÍÍÍÍÍÍͼ");
  656.   colour (6, 0);
  657.   display (4, 1, "10000 (known as 'Zonk' or 'Zilch' to some) is a game I first learned from my");
  658.   display (5, 1, "grandparents back in the forgotten mists of childhood, but other than that I ");
  659.   display (6, 1, "have no idea from whence it originated.  However, it is a somewhat addictive");
  660.   display (7, 1, "game which I thought deserved some development in the cybernetic realm.  I do");
  661.   display (8, 1, "acknowledge, however, that this idea was not mine originally.  The basic layout");
  662.   display (9, 1, "and operation of this version is horked heavily from my cousin (Brad Randall)");
  663.   display (10, 1, "and his 1986 GWBasic version for the PC, although aside from a few variable");
  664.   display (11, 1, "names my code bears no similarity to his.  This version was written as an");
  665.   display (12, 1, "exercise in cross-platform programming and is unique in that both the IBM and");
  666.   display (13, 1, "Amiga versions share identical code (albeit markedly different include files.)");
  667.   colour (5, 0);
  668.   display (15, 1, "ÚÄÄÄÄÄÄÄÄÄÄÄ·");
  669.   display (16, 1, "³ THE RULES º");
  670.   display (17, 1, "ÔÍÍÍÍÍÍÍÍÍÍͼ");
  671.   colour (6, 0);
  672.   display (18, 1, "The rules of play are simple.  Each player starts with 0 (of course) and rolls");
  673.   display (19, 1, "5 dice.  The player holds back at least one scoreable die (this will be");
  674.   display (20, 1, "explained in detail later) and rolls the remaining dice, adding to this running");
  675.   display (21, 1, "total until he/she decides to quit rolling and add the running total to his/her");
  676.   display (22, 1, "score.  If all five dice have been held aside as scoreable (in one or several");
  677.   display (23, 1, "rolls) then all five are rolled again.  Sound easy?  Well, there's a couple of");
  678.   colour (2, 0);
  679.   pause ();
  680.   cls ();
  681.   colour (6, 0);
  682.   display (1, 1, "catches.");
  683.   colour (14, 0);
  684.   display (3, 1, "1) If any roll comes up with zero scoring dice, this is called a 'Zonk' and the");
  685.   display (4, 1, "dice are passed to the next player.  A Zonk which occurs when all five dice are");
  686.   display (5, 1, "rolled is called a 'Grand Wazoo.'  Different name, same result.");
  687.  
  688.   display (7, 1, "2) Before a player can stop rolling and keep his/her score, he/she must be 'on");
  689.   display (8, 1, "the board.'  The minimum score for being on the board starts at 1000 and");
  690.   display (9, 1, "eventually decreases to 500 after the first person on the board has had 5");
  691.   display (10, 1, "additional turns.  So, before a player can stop and keep his/her running total,");
  692.   display (11, 1, "it must exceed the minimum for being 'on the board.'");
  693.   colour (6, 0);
  694.   display (13, 1, "Once a player's score reaches or exceeds 10000, the other players are given one");
  695.   display (14, 1, "additional turn to try and beat him/her.  At the end of this last round of");
  696.   display (15, 1, "play, the person (or artificially-intelligent computer-generated substitute, as");
  697.   display (16, 1, "the case may be) with the highest score is declared the weiner... uh.. winner.");
  698.   colour (2, 0);
  699.   pause ();
  700.   cls ();
  701.   colour (5, 0);
  702.   display (1, 1, "ÚÄÄÄÄÄÄÄÄÄÄ·");
  703.   display (2, 1, "³ THE DICE º");
  704.   display (3, 1, "ÔÍÍÍÍÍÍÍÍÍͼ");
  705.   colour (6, 0);
  706.   display (4, 1, "The following dice (in the combinations listed) are considered 'scoreable.'");
  707.   colour (10, 0);
  708.   display (6, 1, "Combination            Score");
  709.   display (7, 1, "ÄÄÄÄÄÄÄÄÄÄÄ            ÄÄÄÄÄ");
  710.   colour (11, 0);
  711.   display (8, 1, "Each 5                 50");
  712.   display (9, 1, "Each 1                 100");
  713.   display (10, 1, "Three-of-a-kind        100 * value of one die (ie. three 2's = 200)");
  714.   display (11, 1, "Three 1's              1000");
  715.   display (12, 1, "Five-of-a-kind         2000");
  716.   colour (6, 0);
  717.   display (14, 1, "Note: A die cannot be scored more than one way, ie. if you use a 5 as part of");
  718.   display (15, 1, "three-of-a-kind to make 500, you cannot also count it as 50.  Also, for any die");
  719.   display (16, 1, "other than 5 or 1 to be held back as scoreable, it must be held back along with");
  720.   display (17, 1, "either 2 or 4 others like it to make three-of-a-kind or five-of-a-kind.");
  721.   colour (5, 0);
  722.   display (19, 1, "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·");
  723.   display (20, 1, "³ THE STRATEGY º");
  724.   display (21, 1, "ÔÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
  725.   colour (6, 0);
  726.   display (22, 1, "Although this is essentially a game of chance, there is the tiniest element of");
  727.   display (23, 1, "strategy involved.  The player can attempt to work the laws of probability");
  728.   colour (2, 0);
  729.   pause ();
  730.   cls ();
  731.   colour (6, 0);
  732.   display (1, 1, "toward his or her favour by carefully deciding which dice to score or re-roll.");
  733.   display (2, 1, "For instance, say I rolled five dice and got");
  734.   colour (11, 0);
  735.   display (4, 1, "   1 - 3 - 2 - 4 - 5");
  736.   colour (6, 0);
  737.   display (6, 1, "Assuming I was on the board, I could keep the 1 and the 5 to add 150 to my");
  738.   display (7, 1, "score, but let's say I was greedy and wanted a bit more.  Instead of keeping");
  739.   display (8, 1, "both the 1 and the 5, a better idea would be to keep just the 1 and roll the");
  740.   display (9, 1, "remaining four dice.  The odds of getting three-of-a-kind or more 1's would");
  741.   display (10, 1, "then be better than if I had kept the 5.  Other finer points of strategy will");
  742.   display (11, 1, "become clear after repeated game play.");
  743.   colour (5, 0);
  744.   display (13, 1, "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·");
  745.   display (14, 1, "³ THE COMPUTER º");
  746.   display (15, 1, "ÔÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
  747.   colour (6, 0);
  748.   display (16, 1, "Computerised opponents are ones whose score boxes appear in blue rather than");
  749.   display (17, 1, "purple.  They have been trained to play the game using all of my own personal");
  750.   display (18, 1, "strategies, so playing against them should be equally as difficult as playing");
  751.   display (19, 1, "against a regular opponent.  However, I also programmed a bit of chance into");
  752.   display (20, 1, "their decision-making, so don't set your watch by whether or not the computer");
  753.   display (21, 1, "will make a certain move.  It may surprise you.");
  754.   colour (2, 0);
  755.   pause ();
  756.   cls ();
  757.   colour (5, 0);
  758.   display (1, 1, "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ·");
  759.   display (2, 1, "³ THE ADDRESS º");
  760.   display (3, 1, "ÔÍÍÍÍÍÍÍÍÍÍÍÍͼ");
  761.   colour (6, 0);
  762.   display (4, 1, "If you like this game and/or would like to see me develop other cross-platform");
  763.   display (5, 1, "games/applications, drop me a line at");
  764.   colour (15, 0);
  765.   display (7, 1, "          drc@nettap.com or drc76795@tree.egr.uh.edu");
  766.   colour (11, 0);
  767.   display (9, 1, "D.R. Commander");
  768.   display (10, 1, "April 26, 1995");
  769.   colour (2, 0);
  770.   pause ();
  771.   cls ();
  772.   drawpic ();
  773. }
  774.  
  775. /*** EXIT ROUTINE ***/
  776. void
  777. quit (int line)
  778. {
  779.   clear (line);
  780.   colour (11, 1);
  781.   if (ask (line, "QUIT: Are you absolutely, unequivocally, positively sure"))
  782.     {
  783.       cls ();
  784.       #if (AMI)
  785.     UEND ();
  786.       #endif
  787.       exit (1);
  788.     }
  789.   clear (line);
  790. }
  791.  
  792. /*** NEW GAME ***/
  793. int
  794. new (void)
  795. {
  796.   colour (11, 5);
  797.   clear(21);
  798.   return (ask (21, "Dost thou want to start a new game"));
  799. }
  800.  
  801. /*** PAUSE THE EXECUTION FOR A SET # OF SECONDS (NOT SYSTEM-SPECIFIC) ***/
  802. void
  803. wait (int seconds)
  804. {
  805.   time_t time (time_t * storage), begin, end;
  806.   double difftime (time_t end, time_t begin);
  807.   begin = time (NULL);
  808.   do
  809.     end = time (NULL);
  810.   while (difftime (end, begin) < (double) seconds);
  811. }
  812.